﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using Lottery.MediaData.Core;

namespace Lottery.UnitTest.L09 {
    [TestFixture]
    public class Table1 {
        [Test]
        public void Test() {
            //9场: 1, 3, 4, 5, 6, 7, 9, 11, 13
            var data = new List<DS>();

            // 第1场
            data.Add(new DS(7, 10, 23)); //7	10	23

            // 第3场
            data.Add(new DS(24, 10, 7)); //24	10	7

            // 第4场
            data.Add(new DS(24, 15, 13));//24	15	13

            // 第5场
            data.Add(new DS(24, 12, 0)); // 24	12	0

            // 第6场
            data.Add(new DS(17, 19, 20)); // 17	19	20

            // 第7场
            data.Add(new DS(23, 15, 14)); //23	15	14

            // 第9场
            data.Add(new DS(24, 17, 1)); // 24	17	1

            // 第11场
            data.Add(new DS(24, 10, 1)); //24	10	1

            // 第13场
            data.Add(new DS(24, 11, 0)); //24	11	0

            var result = DSHelper.ProcessAllData(data);

            var r = new[] { 
                new { Key = 24, Value = 6 },
                new { Key = 23, Value = 2 },
                new { Key = 20, Value = 1 },
                new { Key = 19, Value = 1 },
                new { Key = 17, Value = 2 },
                new { Key = 15, Value = 2 },
                new { Key = 14, Value = 1 },
                new { Key = 13, Value = 1 },
                new { Key = 12, Value = 1 },
                new { Key = 11, Value = 1 },
                new { Key = 10, Value = 3 },
                new { Key = 7, Value = 2 },
                new { Key = 1, Value = 2 },
                new { Key = 0, Value = 2 },
            };

            Assert.AreEqual(r.Length, result.Count, "No 0");
            for (int i = 0; i < r.Length; i++) {
                Assert.AreEqual(r[i].Key, result.ElementAt(i).Key, string.Format("No {0}-1", i + 1));
                Assert.AreEqual(r[i].Value, result.ElementAt(i).Value, string.Format("No {0}-2", i + 1));
            }
        }
    }
}
